<!--
 * @Description: 
 * @Author: shilinzhou
 * @Date: 2024-03-05 18:57:02
 * @LastEditors: shilinzhou
 * @LastEditTime: 2024-03-15 15:06:40
-->
<script setup lang="ts">
import MaterialClassify from '@/views/Base/MaterialsManagement/view/MaterialClassify/index.vue';
import MaterialUnit from '@/views/Base/MaterialsManagement/view/MaterialUnit/index.vue';
const materialClassifyRef = ref();
const materialUnitRef = ref();
/**
 * 新增/编辑
 */
const { visible, loading, handleCancel, handleFullscreen } = useModal();

/**
 * 物料设置弹窗打开事件
 */
const handleDialog = () => {
    visible.value = true;
};

const activeName = ref('MaterialClassify');

defineExpose({
    handleDialog
});

/**
 * 物料设置里面不同的tab确认新增事件
 */
const handleOk = () => {
    if (activeName.value === 'MaterialClassify') {
        materialClassifyRef.value.handleOk();
    } else {
        materialUnitRef.value.handleOk();
    }
};
</script>
<template>
    <q-modal
        v-model:visible="visible"
        title="物料分类设置"
        :close-cancel="true"
        :fullscreen="true"
        :confirm-loading="loading"
        width="900px"
        ok-text="确定"
        @ok="handleOk"
        @cancel="handleCancel"
        @fullscreen="handleFullscreen"
    >
        <div style="margin: -24px">
            <el-tabs v-model="activeName">
                <el-tab-pane label="物料分类" name="MaterialClassify">
                    <MaterialClassify ref="materialClassifyRef" />
                </el-tab-pane>
                <el-tab-pane label="物料单位" name="MaterialUnit">
                    <MaterialUnit ref="materialUnitRef" />
                </el-tab-pane>
            </el-tabs>
        </div>
    </q-modal>
</template>

<style scoped lang="scss"></style>
